home *** CD-ROM | disk | FTP | other *** search
- isometricAS = function(maxx, maxz)
- {
- this.maxx = maxx;
- this.maxz = maxz;
- this.theta = 30;
- this.alpha = 45;
- this.theta *= 0.017453292519943295;
- this.alpha *= 0.017453292519943295;
- this.sinTheta = Math.sin(this.theta);
- this.cosTheta = Math.cos(this.theta);
- this.sinAlpha = Math.sin(this.alpha);
- this.cosAlpha = Math.cos(this.alpha);
- };
- isometricAS.prototype.mapToScreen = function(xpp, ypp, zpp)
- {
- var yp = ypp;
- var xp = xpp * this.cosAlpha + zpp * this.sinAlpha;
- var zp = zpp * this.cosAlpha - xpp * this.sinAlpha;
- var x = xp;
- var y = yp * this.cosTheta - zp * this.sinTheta;
- return [x,y];
- };
- isometricAS.prototype.mapToIsoWorld = function(screenX, screenY)
- {
- var z = (screenX / this.cosAlpha - screenY / (this.sinAlpha * this.sinTheta)) * (1 / (this.cosAlpha / this.sinAlpha + this.sinAlpha / this.cosAlpha));
- var x = 1 / this.cosAlpha * (screenX - z * this.sinAlpha);
- return [x,z];
- };
- isometricAS.prototype.calculateDepth = function(x, y, z)
- {
- var leeway = 5;
- var x = Math.abs(x) * leeway;
- var y = Math.abs(y);
- var z = Math.abs(z) * leeway;
- var a = this.maxx;
- var b = this.maxz;
- var floor = a * (b - 1) + x;
- var depth = a * (z - 1) + x + floor * y;
- return depth;
- };
-